package com.mcode.admin.controller;

import com.mcode.admin.model.params.PageParam;
import com.mcode.admin.pojo.Permission;
import com.mcode.admin.service.PermissionService;
import com.mcode.admin.vo.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("admin")
public class AdminController {

    @Resource
    private PermissionService permissionService;

    @PostMapping("/permission/permissionList")
    public Result permissionList(@RequestBody PageParam pageParam) {
        return Result.success(permissionService.listPermission(pageParam));
    }

    @PostMapping("/permission/add")
    public Result add(@RequestBody Permission permission) {
        permissionService.add(permission);
        return Result.success(null);
    }

    @PostMapping("/permission/update")
    public Result update(@RequestBody Permission permission) {
        permissionService.update(permission);
        return Result.success(null);
    }

    @GetMapping("/permission/delete/{id}")
    public Result delete(@PathVariable("id") Long id) {
        permissionService.delete(id);
        return Result.success(null);
    }

}
